<?php

namespace App\Http\Controllers\admin;

use App\CommentModel;
use App\Http\Controllers\Controller;
use App\UserModel;
use Illuminate\Http\Request;
use function Symfony\Component\Console\Tests\Command\createClosure;

class CommentController extends Controller
{
    public function insertcomment(Request $request)
    {
//        dd($request->input());

        $ar_id = $request->input("ar_id");
        $content = $request->input("content");
        $openid = $request->input("openid");
        $ok = CommentModel::create($request->input());
        return $ok;
    }

    public function getcomment(Request $request)
    {
        $ar_id = $request->input("ar_id");
        $cols = ["user.*", "comment.*"];
        $comment = CommentModel::leftjoin("user", "comment.openid", "user.openid")->where("comment.ar_id", $ar_id)->get($cols);
        foreach ($comment as $com) {
            $com->nickName = base64_decode($com->nickName);
        }
        return $comment;
    }
}
